#include <iostream>
#include <iomanip>
#include <limits>

using namespace std;

double C_to_F(double celsius) {
    return (celsius * 9.0 / 5.0) + 32;
}

double F_to_C(double fahrenheit) {
    return (fahrenheit - 32) * 5.0 / 9.0;
}

int main() {
    int choice;
    double temp;

    do {
        cout << "1. Convert Celsius to Fahrenheit" << endl;
        cout << "2. Convert Fahrenheit to Celsius" << endl;
        cin >> choice;

        if (cin.fail()) {
            cin.clear();
            cin.ignore(numeric_limits<streamsize>::max(), '\n');
            continue;
        }

        switch (choice) {
            case 1:
                cout << "Enter temperature in Celsius: ";
                cin >> temp;
                cout << fixed << setprecision(2);
                cout << temp << "°C = " <<C_to_F(temp) << "°F" << endl;
                break;
            case 2:
                cout << "Enter temperature in Fahrenheit: ";
                cin >> temp;
                cout << fixed << setprecision(2);
                cout << temp << "°F =" << F_to_C(temp) << "°C" << endl;
                break;
            default:
                cout << "Invalid choice.1 Please enter a number between 1 and 2." << endl;
                break;
        }
    } while (choice != 2);

    return 0;
}